package javabasic.singleton.ehanshi;


/**
 * 枚举类中定义的每一个常量都是当前类的一个对象，在枚举类中也可以定义自己的方法
 */
public enum Singleton0202 {
    INSTANCE,INSTANCE02,INSTANCE03;
    public void printSingleton0202(){
        System.out.println(this.name());
    }

    public static void main(String[] args) {
        System.out.println(Singleton0202.INSTANCE.getClass());
        Singleton0202.INSTANCE.printSingleton0202();
        System.out.println(Singleton0202.INSTANCE.ordinal());
        System.out.println(Singleton0202.INSTANCE02.getClass());
        Singleton0202.INSTANCE02.printSingleton0202();
        System.out.println(Singleton0202.INSTANCE02.ordinal());
        System.out.println(Singleton0202.INSTANCE03.getClass());
        Singleton0202.INSTANCE03.printSingleton0202();
        System.out.println(Singleton0202.INSTANCE03.ordinal());
        System.out.println(Singleton0202.INSTANCE==Singleton0202.INSTANCE);
        System.out.println(Singleton0202.INSTANCE03==Singleton0202.INSTANCE02);
    }
}
